package pro.cherish.knowledgeumldesignpattern.designPattern.com.cherish.singleton;

import java.util.concurrent.CountDownLatch;

public class client3 {

    public static void main(String [] args) throws Exception{
        long start = System.currentTimeMillis();
        int threadNumn=10;
//       需要添加final，复制一个副本
        final CountDownLatch cd=new CountDownLatch(threadNumn);
        for (int j=0;j<threadNumn;j++){
            new Thread(new Runnable() {
                @Override
                public void run() {
                    for (int i=0;i<100000;i++){
                        Object o=T04.getInstance();
                    }
                    cd.countDown();
                }
            }).start();
        }
//        mian 阻塞 直到计数器变为0 才会继续往下进行
        cd.await();
        long end = System.currentTimeMillis();
        System.out.println(end-start);
    }
}
